package com.fire.control.system.support.protocol.comman;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fire.control.system.statics.ResponseMessage;

/****
 * 
 * @ClassName:  ResponseJsonProtocol   
 * @Description: 返回JSON格式的协议。   
 * @author:   chenchuang
 * @date:   2017年4月25日 下午2:48:52   
 *
 */

public class ResponseJsonProtocol extends ResponseProtocol{

	private static final long serialVersionUID = 1L;
	
	@Override
	public String toString() {
		ObjectMapper jackson = new ObjectMapper();
		try {
			return jackson.writeValueAsString(this);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public ResponseJsonProtocol() {
		setCode(ResponseMessage.CODE_200.getCode());
		setMessage(ResponseMessage.CODE_200.getMessage());
		setIsSuccess(ResponseMessage.CODE_200.isSuccess());
	}
	
	public ResponseJsonProtocol(int code,String message,boolean isSuccess) {
		setCode(code);
		setMessage(message);
		setIsSuccess(isSuccess);
	}
	

}
